package com.zego.base.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>Copyright © 2017 Zego. All rights reserved.</p>
 *
 * @author realuei on 24/10/2017.
 */

public class TimeUtil {
    static final private SimpleDateFormat sFormat = new SimpleDateFormat("yyMMddHHmmssSSS");
    static final private SimpleDateFormat sLogFormat = new SimpleDateFormat("HH:mm:ss.SSS");

    static public String getNowTimeStr() {
        return sFormat.format(new Date());
    }

    static public String getLogStr() {
        return sLogFormat.format(new Date());
    }

    /**
     * 获取当前时间戳，以秒为单位
     */
    public static String getCurrentTimeMil() {
        return System.currentTimeMillis() / 1000 + "";
    }

    /**
     * 格式化当前时间
     */
    public static String getCurrentTime() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date curDate = new Date(System.currentTimeMillis());// 获取当前时间
        return formatter.format(curDate);
    }
}
